y.label <- c("Dem. circuit,\nunified panel", "Dem. circuit,\nmixed panel", 
  "Rep. circuit,\nunified panel", "Rep. circuit,\nmixed panel")
dem.mean.vector <- c(mean(dem.judges.prob.dem.circuit.unified.vector), mean(dem.judges.prob.dem.circuit.mixed.vector),
  mean(dem.judges.prob.gop.circuit.unified.vector), mean(dem.judges.prob.gop.circuit.mixed.vector))
dem.ci.matrix <- rbind(quantile(dem.judges.prob.dem.circuit.unified.vector, c(.025, .975)),
  quantile(dem.judges.prob.dem.circuit.mixed.vector, c(.025, .975)),
  quantile(dem.judges.prob.gop.circuit.unified.vector, c(.025, .975)),
  quantile(dem.judges.prob.gop.circuit.mixed.vector, c(.025, .975)))
gop.mean.vector <- c(mean(gop.judges.prob.dem.circuit.unified.vector), mean(gop.judges.prob.dem.circuit.mixed.vector),
  mean(gop.judges.prob.gop.circuit.unified.vector), mean(gop.judges.prob.gop.circuit.mixed.vector))
gop.ci.matrix <- rbind(quantile(gop.judges.prob.dem.circuit.unified.vector, c(.025, .975)),
  quantile(gop.judges.prob.dem.circuit.mixed.vector, c(.025, .975)),
  quantile(gop.judges.prob.gop.circuit.unified.vector, c(.025, .975)),
  quantile(gop.judges.prob.gop.circuit.mixed.vector, c(.025, .975)))

y <- 4:1
line.width <- 2
axis.size <- 1.4

pdf("figure4a.pdf", height = 10, width = 6)

par(mfrow = c(2,1), mar = c(5, 8, 3, 0.5))

#gop
plot(gop.mean.vector, y, axes = F, xlim = c(.2, .8), xlab = "", ylab = "", 
    main = "", type = "n")
polygon(x = c(0,0,.8,.8), y = c(2.5,4.5,4.5,2.5), col = "gray75", border = T)
points(gop.mean.vector, y,  pch = 19, cex = 1.5)
axis(1, at = seq(.2,.8,.1),  mgp = c(2,.8,0), cex.axis = axis.size)
axis(2, at = y, labels = y.label, las =1, mgp = c(2,.7,0), cex.axis = axis.size)
segments(gop.ci.matrix[,1], y, gop.ci.matrix[,2],y, lwd = line.width)
segments(.15,y,.8,y, lty="dotted")
mtext("Republican majorities", 3, line = .5, cex =1.9, font = 2)
mtext("Average predicted probability\nof a liberal vote", 1, line =3.5, cex =1.3, font = 3)
text(.09,3.5, "Add a D", xpd=T, font = 2, col = "blue")
arrows(.15, 3.8, .15,3.2, xpd=T, length = .2, col = "blue")
text(.09,1.5, "Add a D", xpd=T, font = 2, col = "blue")
arrows(.15, 1.8, .15,1.2, xpd=T, length = .2, col = "blue")
#note: actual differences may change slightly across simulations
text(.74, 3.5, "+ 2%", cex = 1.5)
text(.74, 1.5, "+ 7%", cex = 1.5)

#dems
plot(dem.mean.vector, y, axes = F, xlim = c(.2, .8), xlab = "", ylab = "", 
    main = "", type = "n")
polygon(x = c(0,0,.8,.8), y = c(2.5,4.5,4.5,2.5), col = "gray75", border = T)
points(dem.mean.vector, y,  pch = 19, cex = 1.5)
axis(1, at = seq(.2,.8,.1),  mgp = c(2,.8,0), cex.axis = axis.size)
axis(2, at = y, labels = y.label, las =1, mgp = c(2,.7,0), cex.axis = axis.size)
segments(dem.ci.matrix[,1], y, dem.ci.matrix[,2],y, lwd = line.width)
segments(.15,y,.8,y, lty="dotted")
mtext("Democratic majorities", 3, line = .5, cex =1.9, font = 2)
mtext("Average predicted probability\nof a liberal vote", 1, line =3.5, cex =1.3, font = 3)
text(.09,3.5, "Add a R", xpd=T, font = 2, col = "red")
arrows(.15, 3.8, .15,3.2, xpd=T, length = .2, col = "red")
text(.09,1.5, "Add a R", xpd=T, font = 2, col = "red")
arrows(.15, 1.8, .15,1.2, xpd=T, length = .2, col = "red")
#note: actual differences may change slightly across simulations
text(.74, 3.5, "- 10%", cex = 1.5)
text(.74, 1.5, "- 19%", cex = 1.5)

dev.off()